home *** CD-ROM | disk | FTP | other *** search
- #include "MST_Defines.h"
- #include "MST_Externs.h"
- #include "MST_Prototypes.h"
- #include "MST_Menus.h"
-
-
- /*_____________________________________________________________________________
- Init-ApplicationMenus()- set up our initial menus
- _____________________________________________________________________________*/
-
-
-
- void Init_ApplicationMenus()
- {
- MenuHandle thisMenu,thatMenu;
- /*
- • Our menus are straightforward and do not change during the course of the
- • program's execution. Our task is further simplified by placing all our
- • menu information in our menu resources (MENU). First we clear the menubar,
- • then add the Apple, File, Edit, and our Chart menus, and finally draw
- • the menubar. InsertMenu adds a menu to the menubar; a zero as the
- • second parameter inserts it at the end. AddResMenu searches for all
- • available resources of a particular type, and tacks them onto the end
- • of a menu as menu items. So AddResMenu (thisMenu, 'DRVR') is how one adds
- • all the Apple Menu Items (formerly desk accessories in system 6 talk...DRVR
- • is the resource type for a desk accessory). Notice how even though Apple
- • completely changed the concept of what appears under the Apple menu,
- • the changes are transparent to your program. Pretty cool, eh?
- */
- ClearMenuBar();
-
- thisMenu = GetMenu (Menu_Apple);
- InsertMenu (thisMenu,0);
- AddResMenu (thisMenu,'DRVR');
-
- InsertMenu (GetMenu (Menu_File),0);
- InsertMenu (GetMenu (Menu_Edit),0);
- InsertMenu (GetMenu(Menu_Chart),0);
-
- DrawMenuBar();
- }
-
-
- /*_____________________________________________________________________________
- Handle-TheMenus()- respond to menu choices
- _____________________________________________________________________________*/
-
-
-
- void Handle_TheMenus (short thisMenu,short thisItem)
- {
- Str255 thisName;
- /*
- • Very straigtforward. Just keep checking for all the possibilities
- • until you find the menu item selected, then take the appropriate action.
- */
- switch (thisMenu)
- {
- case Menu_Apple:
- {
- switch (thisItem)
- {
- /*
- • If our About MacSciTech menu item was selected, then open our About Box.
- */
- case Item_AboutMST:
- {
- Open_AboutMST();
- break;
- }
- /*
- • Otherwise launch the Apple Menu Item selected. Note the call OpenDeskAcc()
- • still works the same way under System 7.
- */
- default:
- {
- GetItem (GetMenu(Menu_Apple),thisItem,&thisName);
- OpenDeskAcc (thisName);
- break;
- }
- }
- break;
- }
- case Menu_File:
- {
- switch (thisItem)
- {
- case Item_Quit:
- {
- /*
- • We only have one item in the File menu: Quit. In most applications, you
- • will have some tidying up to do, like asking if the user wants to save
- • work to disk. A useful technique is to set Quitting to TRUE, and use it
- • as a flag to stop handling null events normally, and instead start cleaning
- • up. When cleaned up, then set a flag called Finished to TRUE, and use
- • Finished as your test criterion in your main event loop.
- */
- Quitting = TRUE;
- break;
- }
- default: break;
- }
- break;
- }
- case Menu_Edit:
- {
- /*
- • We don't handle any edit functions.
- */
- break;
- }
- case Menu_Chart:
- {
- switch (thisItem)
- {
- /*
- • Open the Periodic Chart window if the Open item was selected under the Chart
- • menu.
- */
- case Item_OpenChart:
- {
- Open_PeriodicChart();
- break;
- }
- /*
- • Or close it if the Close item was selected.
- */
- case Item_CloseChart:
- {
- Close_PeriodicChart();
- break;
- }
- default: break;
- }
- break;
- }
- }
- /*
- • Finally, you need to call HiliteMenu(0) in order to unhighlight the menu
- • selected. (The call to MenuSelect() in the main event loop leaves the menu
- • highlighted.)
- */
- HiliteMenu(0);
- }
-
-